/**
 * @param {number[][]} costs
 * @return {number}
 */

// 动态规划
var minCost = function (costs) {
  let red = 0, blue = 0, green = 0
  for (const [r, b, g] of costs) {
    [red, blue, green] = [Math.min(blue, green) + r, Math.min(red, green) + b, Math.min(red, blue) + g]
  }
  console.log((red, blue, green));
  return Math.min(red, blue, green)
};

costs = [[[3, 5, 3], [6, 17, 6], [7, 13, 18], [9, 10, 18]]]

minCost(costs)